package cn.itcast.bos.web.action.take_delivery;


import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.take_delivery.Order;
import cn.itcast.bos.service.take_delivery.OrderService;
import cn.itcast.bos.web.action.common.BaseAction;

@SuppressWarnings("serial")
@Namespace("/")
@ParentPackage("json-default")
@Controller
@Scope("prototype")
public class OrderAction extends BaseAction<Order>{
	
	@Autowired
	private OrderService orderService;
	private static Logger logger = Logger.getLogger(Order.class);
	
	@Action(value="findByOrderNum",results={@Result(name="success",type="json")})
	public String findByOrderNum(){
		Map<String,Object> map = new HashMap<>();
		Order order = orderService.findByOrderNum(model.getOrderNum());
		if(order != null){
			//数据库存在
			map.put("msg", true);
			map.put("orderData", order);
			logger.info("已存在的order回显");
		}else{
			map.put("msg", false);
			logger.info("没有查询到该order对象");
		}
		ActionContext.getContext().getValueStack().push(map);
		return SUCCESS;
	}

}
